<template>
  <view class="curriulum-list">
    <view class="curriulum-item" v-for="(item, i) in curriulumResults" :key="i" @click="gotoDetail(item)">
      <view class="curriulum-name">{{item.id}}.{{item.name}}</view>
      <uni-icons type="arrowright" size="16"></uni-icons>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        // 课程选择的数据列表
        curriulumResults: []
      };
    },
    onLoad() {
      // 获取课程列表
      this.getCurriulumResults()
    },
    methods: {
      gotoDetail(item) {
        // console.log(item.goods_id)
        uni.navigateTo({
          // pj1003 发送课程ID 和 名字
          url: '../pj1003/pj1003?curriulum_id=' + item.id + '&curriulum_name=' + item.name
        })
      },
      async getCurriulumResults() {
        const {
          data: res
        } = await uni.$http.get('?command=pj1002')
        //console.log(res.data)
		if(res.success) {
			this.curriulumResults = res.data
		} else {
			uni.showToast({
				icon: 'error',
				title: '失败'
			});
		}
      }
    }
  }
</script>

<style lang="scss">
  .curriulum-list {
    padding: 0 5px;

    .curriulum-item {
      font-size: 12px;
      padding: 13px 0;
      border-bottom: 1px solid #efefef;
      display: flex;
      align-items: center;
      justify-content: space-between;

      .curriulum-name {
        // 文本不允许换行
        white-space: nowrap;
        // 溢出部分隐藏
        overflow: hidden;
        // 文本溢出后，使用。。。代替
        text-overflow: ellipsis;
        margin-right: 3px;
      }
    }
  }
</style>
